package com.zsrt.bbu.bank.dao.impl;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;

import org.springframework.stereotype.Repository;

import com.zsrt.bbu.bank.dao.BankDao;
import com.zsrt.common.entity.Combobox;
import com.zsrt.utils.DBUtil;


@Repository
public class BankDaoImpl implements BankDao {

	@Override
	public List<Combobox> findAll() throws Exception {
		List<Combobox>  list = new ArrayList<Combobox>();
		
		String sql = "select id as valueField , BANK_NAME as textField  from bbu_bank_t";
		Connection connection = DBUtil.getConnection();
		PreparedStatement ps = connection.prepareStatement(sql);
		ResultSet rs = ps.executeQuery();
		
		while(rs.next()) {
			Combobox dep= new Combobox();
			dep.setValueField(rs.getString("valueField"));
			dep.setTextField(rs.getString("textField"));
			list.add(dep);
			
		}
		DBUtil.closeResources(rs, ps, connection);
		return list;
	}


}
